<?php
  function check_url($url) { 
    $url_parts = parse_url($url); 
    if (!$fp = @fsockopen ($url_parts['host'], isset($url_parts['port']) ? $url_parts['port'] : 80)) 
       return FALSE; 
    $request = 'HEAD '. 
      (isset($url_parts['path']) ? $url_parts['path'] : '/'). 
      (isset($url_parts['query']) ? '?'.$url_parts['query'] : ''). 
      ' HTTP/1.1'."\r\n". 
      'Host: '.$url_parts['host']."\r\n\r\n"; 
    fputs ($fp, $request); 
    stream_set_timeout($fp, 5); 
    $found = explode(' ', fgets($fp,128), 2); 
    fclose($fp); 
    return (isset($found[1]) ? $found[1] : FALSE); 
  }  

?>